<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('更新apk文件')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-recruitTeam-add" th:object="${forceReplace}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">APK安装包：</label>
                <div class="col-sm-8">
                <div class="fileinput fileinput-new" data-provides="fileinput">
                    <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;"></div>
                    <div>
                        <span class="btn btn-white btn-file"><span class="fileinput-new">选择安装包</span><span class="fileinput-exists">更改</span>
                            <input type="file" name="apkFile"></span>
                        <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                    </div>
                </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "forceReplace/forceReplace";
        function submitHandler() {
            if ($.validate.form()) {
                var formData = new FormData();
                formData.append("apkFile", $("input[name='apkFile']").get(0).files[0]);
                formData.append("id",$("input[name='id']").val());

                $.ajax({
                    url : prefix + "/saveApkPackage",
                    type: 'POST',
                    data: formData,
                    cache: false,
                    contentType: false,
                    processData: false,
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                        $.modal.disable();
                    },
                    success : function(result) {
                        if (result.code == web_status.SUCCESS) {
                            var parent = window.parent;
                            if (parent.table.options.type == table_type.bootstrapTable) {
                                $.modal.close();
                                parent.$.modal.msgSuccess(result.msg);
                                parent.$.table.refresh();
                            } else if (parent.table.options.type == table_type.bootstrapTreeTable) {
                                $.modal.close();
                                parent.$.modal.msgSuccess(result.msg);
                                parent.$.treeTable.refresh();
                            } else {
                                $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
                            }
                        } else if (result.code == web_status.WARNING) {
                            $.modal.alertWarning(result.msg)
                        }  else {
                            $.modal.alertError(result.msg);
                        }
                        $.modal.closeLoading();
                        $.modal.enable();
                        //$.modal.alertSuccess(data.msg)
                    },
                    error : function(result) {
                        $.modal.alertError(result.msg);
                    }
                });
            }
        }
    </script>
</body>
</html>